package com.guigu.design;

public class InterfaceSingle {
    public static void main(String[] args){
        C c = new C();
        c.print1(new A());
        c.print2(new A());

        D d = new D();
        d.print2(new B());
        d.print3(new B());
    }
}

interface Interface1{
    void print1();

    void print2();
}

interface Interface2{
    void print3();

    void print4();
}


class A implements Interface1{

    public void print1() {
        System.out.println("方法1");
    }

    public void print2() {
        System.out.println("方法2");
    }
}

class B implements Interface2{

    public void print3() {
        System.out.println("方法3");
    }

    public void print4() {
        System.out.println("方法4");
    }
}

class C {

    public void print1(Interface1 interface1){
        interface1.print1();
    }

    public void print2(Interface1 interface1){
        interface1.print2();
    }
}


class D {

    public void print3(Interface2 interface2){
        interface2.print3();
    }

    public void print2(Interface2 interface2){
        interface2.print4();
    }
}


